﻿@model Shop.Models.ProductInfo

@{
    ViewBag.Title = "CreateInfo";
    Layout = "~/Areas/Admin/Views/Shared/_LayoutForm.cshtml";
}

@using (Ajax.BeginForm("CreateInfo", null,new AjaxOptions()
{
    OnSuccess= "onSuccess"
},new {@class= "form-horizontal" })
    )
{
    @Html.AntiForgeryToken()
    
<div class="form-horizontal">

    @Html.ValidationSummary(true, "", new { @class = "text-danger" })
    @Html.HiddenFor(model => model.ProductId)

    <div class="form-group">
        @Html.LabelFor(model => model.Name, htmlAttributes: new { @class = "control-label col-md-2" })
        <div class="col-md-10">
            @Html.EditorFor(model => model.Name, new { htmlAttributes = new { @class = "form-control" } })
            @Html.ValidationMessageFor(model => model.Name, "", new { @class = "text-danger" })
        </div>
    </div>



    <div class="form-group">
        @Html.LabelFor(model => model.ROM, htmlAttributes: new { @class = "control-label col-md-2" })
        <div class="col-md-10">
            @Html.EditorFor(model => model.ROM, new { htmlAttributes = new { @class = "form-control" } })
            @Html.ValidationMessageFor(model => model.ROM, "", new { @class = "text-danger" })
        </div>
    </div>

    <div class="form-group">
        @Html.LabelFor(model => model.Storage, htmlAttributes: new { @class = "control-label col-md-2" })
        <div class="col-md-10">
            @Html.EditorFor(model => model.Storage, new { htmlAttributes = new { @class = "form-control" } })
            @Html.ValidationMessageFor(model => model.Storage, "", new { @class = "text-danger" })
        </div>
    </div>

    <div class="form-group">
        @Html.LabelFor(model => model.CPU, htmlAttributes: new { @class = "control-label col-md-2" })
        <div class="col-md-10">
            @Html.EditorFor(model => model.CPU, new { htmlAttributes = new { @class = "form-control" } })
            @Html.ValidationMessageFor(model => model.CPU, "", new { @class = "text-danger" })
        </div>
    </div>

    <div class="form-group">
        @Html.LabelFor(model => model.Price, htmlAttributes: new { @class = "control-label col-md-2" })
        <div class="col-md-10">
            @Html.EditorFor(model => model.Price, new { htmlAttributes = new { @class = "form-control" } })
            @Html.ValidationMessageFor(model => model.Price, "", new { @class = "text-danger" })
        </div>
    </div>

    <div class="form-group">
        <div class="col-md-offset-2 col-md-10">
            <input type="submit" value="提交" class="btn btn-default" />
        </div>
    </div>
</div>
}

@section scripts{
    <script>
        function onSuccess(res) {
            if (res.success) {
                parent.closeModal(); // 调用父窗口中的方法用来关闭窗口、刷新数据
            } else {
                alert(res.msg)
            }
        }

    </script>
    
    }


